'use strict';

module.exports = app => {
    const { STRING, INTEGER, DATE, TEXT, ENUM } = app.Sequelize;

    const UserResumes = app.model.define('user_resumes', {
        id: {
            type: INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        user_id: {
            type: INTEGER,
            allowNull: false,
        },
        real_name: STRING(255),
        sex: ENUM('男', '女'),
        work_start_time: DATE,
        birth_day: STRING(255),
        avatar: STRING(255),
        want_location: STRING(255),
        want_price_month: STRING(255),
        want_position: STRING(255),
        phone: STRING(255),
        wechat_no: {
            type: STRING(255),
            defaultValue: '',
        },
        personal_advantage: TEXT,
        qualifications_certificate: TEXT,
        skills_certificate: STRING(255),
        health_certificate: STRING(255),
        created_at: DATE,
        updated_at: DATE,
    }, {
        timestamps: true,
        tableName: 'user_resumes',
    });

    UserResumes.associate = function() {
        app.model.UserResumes.hasMany(app.model.UserResumeExperience, { as:'experiences', foreignKey: 'resume_id' });
      };

    return UserResumes;
};
